﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<%@include file="../../commons/meta.jsp"%>
<c:set var="baseUrl" value="${ctx}api/volunteer-forecast/"
	scope="request" />
<link rel="stylesheet" href="${ctx}assets/plugins/pure/pure-min.css"
	media="all" />
<script type="text/javascript"
	src="${ctx}assets/plugins/plupload/2.2.1/js/plupload.full.min.js"></script>
<script type="text/javascript"
	src="${ctx}assets/plugins/plupload/2.2.1/js/i18n/zh_CN.js"></script>
	<script type="text/javascript">
function validateForm(){
	if(empty($("#provinceName").val()) ){
		alertError("请选择省份！");
		return false;
	}
	if(empty($("#direction").val()) ){
		alertError("请选择学科！");
		return false;
	}
	
	if(empty($("#lowestScore").val())){
		alertError("请输入考生分数");
		return false;
	}
	listFormPageSearch(1);
};


</script>
</head>
<body>
	<%@include file="../../commons/head.jsp"%>
	<div class="content">
		<%@include file="../../commons/menu.jsp"%>
		<!--右侧展示部分-->
		<div class="right-zq">
			<!--center content-->
			<div class="dynamic">
				<form id="listForm" action="${ctx}api/volunteer-forecast/"
					method="post">
					<div class="role dynamiclayer" style="display: block;">
						<div class="title orange2">
							<span class="left">志愿管理</span> <label> > </label> <span>志愿填报预测</span>
						</div>
						<!-- class标识查询区域的高度 -->
						<div class="role-input">
							<ul class="input">
							<!-- name="searchMap.provinceName,eq,string" -->
								<li class="p28">省份： <select id="provinceName"
									name="provinceName"
									style="text-align: center;" class="input1">
								</select>
								</li>
								<!-- name="searchMap.direction,eq,int" -->
								<li class="p28">学科： <select id="direction"
									name="direction" class="input1"
									style="text-align: center;">
										<option value="">全部</option>
										<option value="1">文科</option>
										<option value="2">理科</option>
								</select>
								</li>
								<!-- name="searchMap.batch,eq,int" -->
								<li class="p28">批次： <select id="batch"
									name="batch" class="input1"
									style="text-align: center;">
										<option value="1">本科一批</option>
										<option value="2">本科二批</option>
										<option value="4">专科</option>
								</select>
								</li>
							</ul>
						</div>

						<div class="role-input">
							<ul class="input">
							<!-- name="searchMap.lowestScore,le,int" -->
								<li class="p40">考生分数： <input type="text" id="lowestScore"
									name="lowestScore" value=""
									placeHolder="请输入考生分数" class="input1 num" maxlength="4" />
								</li>
								<li class="p20">
									<div class="button">
										<span class="orange2" onclick="validateForm()">查询</span>
									</div>
								</li>
							</ul>

						</div>
						<div class="role-table role-table2">
							<table cellspacing="0px" id="datatable">
							</table>
						</div>
						<div class="role-page">
							<input type="hidden" id="pageSize" name="pageSize" value="10" />
							<ul id="datapagefoot">
							</ul>
						</div>
					</div>
				</form>
			</div>
			<!--center content over-->
		</div>
	</div>
	<script type="text/javascript">
 function getHeadTd(name) {
  return '<td class="head"><span>' + name + '</span></td>';
 }

 function getHead(headArray) {
  var tr = "<tr>";
  $.each(headArray, function (index, item) {
   tr += getHeadTd(item);
  });
  tr += "</tr>";
  return tr;
 }

 function getValueTd(value) {
  return '<td>' + value + '</td>';
 }

 function getValueTr(valueArray) {
  var tr = "<tr>";
  $.each(valueArray, function (index, item) {
   tr += getValueTd(item);
  });
  tr += "</tr>";
  return tr;
 }

 function filtUndef(value) {
  if (typeof(value) == "undefined") {
   return "";
  }
  return value;
 }

 function convertLevel(params) {
  var level = params;
  var result = "";
  if (level == 1) {
   result = "文科";
  } else if (level == 2) {
   result = "理科";
  } else {
   result = "--";
  }
  return result;
 }

 var defaultPageFoot = '';//datapagefoot
 defaultPageFoot += '<li><a class="first orange2-text" id="firstPage" href="javascript:void(0);"><fmt:message key="sys.home"/></a></li>';
 //<li><a class="next orange-text orange-border" id="pagesNextPage" href="javascript:void(0);"><fmt:message key="member.nextPage"/></a></li>
 defaultPageFoot += '<li>共<label class="num"  id="pagesPageCount">0</label>页，每页<label class="num">10</label>条，';
 defaultPageFoot += '到第<input type="text" id="pageNumers" name="pageNumber" value="1" maxlength="9" onpaste="return false;" class="num" />页';
 defaultPageFoot += '<span class="confirm orange2-text orange2-border"  onclick="listFormPageSearch(1)"><fmt:message key="determine"/></span></li>';

 /**分页查询*/
 function listFormPageSearch(pageNum) {
  var pageForm = $("#listForm").serializeObject();
  //var pageCounts = $("#pageCounts").val();
  //checkPageNumber(pageForm, pageNum);

  //var searchMap = [];
  /*$.each(pageForm, function (name, value) {
   if (name.indexOf('searchMap') >= 0) {
    var searchMapMeta = {};
    delete pageForm[name];
    var name2 = name.replace("searchMap.", "");
    searchMapMeta[name2] = value;
    searchMap.push(name2 + "," + value);
   }
  });
  pageForm.searchList = searchMap;
  // 默认按照分数倒序排序
  pageForm.sort="lowestScore";
  pageForm.order="desc";*/
  var searchJsonUrl = 'api/volunteer-forecast/list';
  var pageData = JSON.stringify(pageForm);
  debugs("ajax pageData 2: " + pageData);
  var tableHead = ['序号','年份','学校代码','方向','学校','学校最低分','录取概率'];

  var tableHtml = getHead(tableHead);
  $.ajax({
   url: searchJsonUrl + "?rand=" + Math.random(),
   data: pageData,
   type: 'POST',
   contentType: "application/json",
   dataType: 'json',
   success: function (pages) {
    //var base = pages.pageSize*(pages.pageNumber-1);
    var tr = "";
    $.each(pages, function (index, item) {
     var trtmp = getValueTr([
         filtUndef(index+1),
      filtUndef(item.year),
      filtUndef(item.collegeCode),
      convertLevel(item.direction),
      filtUndef(item.collegeName),
      filtUndef(item.collegeLowScore),
      filtUndef(item.rateName)
      ]);
     tr += trtmp;
    });
    if (isEmpty(tr)) {
     tr = "<tr><td colspan='" + tableHead.length + "' class='error'><fmt:message key='Temporarily.no.data'/></td></tr>";
    }

    $("#datatable").html(tableHtml + tr);
    //$("#pageSize").val(pages.pageSize);
    //$("#datapagefoot").html(getPageFoot(pages));
    //解决当上次查询无数据时，弹出 “请输入合理的页码范围!”提示
    /* if ($("#pageCounts").val() == "0") {
     $("#pageCounts").val("");
    } */
   },
   error: function (xhr) {
    alertError("<fmt:message key='sys.message.searcherror'/>");//请求失败遇到异常触发
    $("#datapagefoot").html(getDefaultPageFoot());
   }
  });
 }

 // 初始化时加载省份下拉框数据
 getProvinceList();

 function getProvinceList() {
   var provinceData = [ "北京", "天津", "上海", "重庆", "河北", "山西", "内蒙古", "辽宁", "吉林",
   "黑龙江", "江苏", "浙江", "安徽", "福建", "江西", "山东", "河南", "湖北", "湖南",
   "广东", "广西", "海南", "四川", "贵州", "云南", "西藏", "陕西", "甘肃", "青海", "宁夏",
   "新疆", "香港", "澳门", "台湾" ];
   var option = "<option value='河南' selected='selected'>河南</option>";
   $.each(provinceData, function(index, item) {
     option += "<option value='" + item + "'>" + item + "</option>";
   });
   $("#provinceName").html(option);
 }
</script>
	<%@include file="../../commons/footpop.jsp"%>
</body>
</html>
